package com.xjscrm.server.web.xxljob;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.xjscrm.server.service.common.XxlJobSyncService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * XxlJob调用
 *
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "XxlJob调用方法", tags = "系统设置|XxlJob调用方法")
@ApiSort(1)
@RestController
public class XxlJobController {

    @Autowired
    private XxlJobSyncService xxlJobSyncService;

    //@Scheduled(cron="0/5 * * * * ?")
    @ApiOperation(value = "5秒执行一次的任务", notes = "5秒执行一次的任务")
    @ApiOperationSupport(order = 1)
    @PostMapping("/xxlJob/executeByPer/5s")
    public Object executeBy5s() {
        xxlJobSyncService.executeBy5s();
        return true;
    }

    @Scheduled(cron="0/10 * * * * ?")
    @ApiOperation(value = "10秒执行一次的任务", notes = "10秒执行一次的任务")
    @ApiOperationSupport(order = 1)
    @PostMapping("/xxlJob/executeByPer/10s")
    public Object executeBy10s() {
        xxlJobSyncService.executeBy10s();
        return true;
    }

    @Scheduled(cron="0/30 * * * * ?")
    @ApiOperation(value = "30秒执行一次的任务", notes = "30秒执行一次的任务")
    @ApiOperationSupport(order = 2)
    @PostMapping("/xxlJob/executeByPer/30s")
    public Object executeBy30s() {
        xxlJobSyncService.executeBy30s();
        return true;
    }

    @ApiOperation(value = "1分钟执行一次的任务", notes = "1分钟执行一次的任务")
    @ApiOperationSupport(order = 3)
    @PostMapping("/xxlJob/executeByPer/1m")
    public Object executeBy1m() {
        return true;
    }

    @ApiOperation(value = "2分钟执行一次的任务", notes = "2分钟执行一次的任务")
    @ApiOperationSupport(order = 4)
    @PostMapping("/xxlJob/executeBy/2m")
    public Object executeBy2m() {
        return true;
    }

    @ApiOperation(value = "5分钟执行一次的任务", notes = "5分钟执行一次的任务")
    @ApiOperationSupport(order = 5)
    @PostMapping("/xxlJob/executeBy/5m")
    public Object executeBy5m() {
        return true;
    }

    @ApiOperation(value = "30分钟执行一次的任务", notes = "30分钟执行一次的任务")
    @ApiOperationSupport(order = 5)
    @PostMapping("/xxlJob/executeBy/30m")
    public Object executeBy30m() {
        return true;
    }

    @ApiOperation(value = "1小时执行一次的任务", notes = "1小时执行一次的任务")
    @ApiOperationSupport(order = 6)
    @PostMapping("/xxlJob/executeBy/1h")
    public Object executeBy1h() {
        return true;
    }

    @ApiOperation(value = "每天凌晨3点执行一次的任务", notes = "每天凌晨3点执行一次的任务")
    @ApiOperationSupport(order = 7)
    @PostMapping("/xxlJob/executeBy/3p")
    public Object executeBy3p() {
        return true;
    }


}
